package task2_2.com.at.count.polsk;

import java.math.BigDecimal;

public class Lexeme {

    /*private static final List FUNCTIONS = new ArrayList(); {
    FUNCTIONS.add("sin");
    FUNCTIONS.add("cos");
    FUNCTIONS.add("pow");
    }*/
    private static final String []types = {"znak","term","function","number","symbol"};

    public static final int TYPE_ZNAK        = 0;//"znak";

    public static final int TYPE_TERM        = 1;//"term";
    public static final int TYPE_FUNCTION    = 2;//"function";
    public static final int TYPE_NUMBER      = 3;//"number";
    public static final int TYPE_SYMBOL      = 4;//"symbol";

    private String value;
    private int type;

    @Deprecated
    private double douleValue;
    private BigDecimal bigDecimalValue;
    private int numberCountUsed;

    public Lexeme(String value, int type) {
        this.value = value;
        this.type = type;

        // this is only for types = "znak" 
        this.numberCountUsed = 2;
    }

    public String getValue() {
        return value;
    }

    public int getType() {
        return type;
    }

    @Deprecated
    public double getDouleValue() {
        return douleValue;
    }

    public BigDecimal getBigDecimalValue() {
        return bigDecimalValue;
    }

    @Deprecated
    public void setDouleValue() {
        if (type == TYPE_NUMBER) {
            douleValue = Double.parseDouble(value);
        }
    }

    public void setBigDecimalValue() {
        if (type == TYPE_NUMBER) {
            bigDecimalValue = new BigDecimal(value);
        }
    }

    @Deprecated
    public void setDouleValue(double doubleValue) {
        douleValue = doubleValue;
    }

    public void setBigDecimalValue(BigDecimal bigDecimalValue) {
        this.bigDecimalValue = bigDecimalValue;
    }

    public String toString() {
        return "Lexem: [Type = " + ((type>=0 && type<=4)? types[type]:"undefined") + "][Value = " + value +"]";
    }

    public int getNumberCountUsed() {
        return numberCountUsed;
    }

    public void setNumberCountUsed(int numberCountUsed) {
        this.numberCountUsed = numberCountUsed;
    }
}
